package edu.nanyang.hibernate;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import edu.nanyang.domain.City;
import edu.nanyang.domain.Province;
import edu.nanyang.domain.School;

public class SwitchCityImpl extends HibernateDaoSupport implements  SwitchCity{
	boolean success;
	@Override
	
	public boolean switchcity(Province provice, City city, School school) {
		Transaction ts = null;

		Session session = getSession();
		ts = session.beginTransaction();
		ts.begin();
		List list = session.createQuery(
				"from edu.nanyang.domain.Province p,City c,School s where p.id='" + provice
						+ "' and c.id='" + city + "' and s.id=' and p.id=c.province_id and c.id=s.city_id;"
						+ school + "'").list();
		
	if (list.size() > 0)
	{
	 success=true;
	}
		ts.commit();

		return success;

	}
	}


